/**
 * @Author：ming
 * @Date：2023/9/27 10:45 AM
 * @Filename：lc212
 */

/**
 * @author ming
 */
public class Lc121 {
    public int maxProfit(int[] prices) {
        int profit = 0;
        int max = 0;
        int minCost =prices[0];
        for(int i=0;i<prices.length;i++){
            profit = prices[i]-minCost;
            if(profit>max){
                max = profit;
            }

            if(prices[i]<minCost){
                minCost = prices[i];
            }
        }

        return max;
    }
}
